﻿using UnityEngine;
using System.Collections;


public class SelectionGUI : MonoBehaviour {
	private Vector3 start, end;
	private bool trackMouse;
	public Material mat;
	// Use this for initialization
	void Start () {
		start = new Vector3(0,0,0);
		end = new Vector3(0,0,0);
		trackMouse = false;
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	public void setDisplay(bool track){
		trackMouse=track;	
	}
	public void setStart(float x, float y){
		start.x=x;
		start.y=y;
	}
	public Vector3 getStart(){
		return start;
	}
	public void setEnd(float x, float y){
		end.x=x;
		end.y=y;
	}
	public Vector3 getEnd(){
		return end;
	}
	void OnPostRender() {
		if(trackMouse){
			GL.PushMatrix();
			mat.SetPass(0);
			GL.LoadOrtho();
			GL.Begin(GL.LINES);
			GL.Color(Color.green);
			GL.Vertex(start);
			GL.Vertex(new Vector3(start.x, end.y, 0));
			GL.Vertex(new Vector3(start.x, end.y, 0));
			GL.Vertex(end);
			GL.Vertex(end);
			GL.Vertex(new Vector3(end.x, start.y, 0));
			GL.Vertex(new Vector3(end.x, start.y, 0));
			GL.Vertex(start);
			GL.End();
			GL.PopMatrix();
		}
	}
}
